package com.demo.third;

import com.alibaba.fastjson.JSONObject;
import com.github.binarywang.demo.wx.cp.aes.HttpUt;
import com.github.binarywang.demo.wx.cp.controller.ThirdBaseController;
import me.chanjar.weixin.common.error.WxErrorException;

/**
 * created by lanxinghua@2dfire.com on 2020/2/14
 * 第三方应用：通讯录管理
 */
public class ThirdAddressBookDemo extends ThirdBaseController {
    public static void main(String[] args) throws Exception {
        listDept(getAccessToken(true));
        listTag(getAccessToken(true));
    }

    /**
     * 获取部门列表
     * @param accessToken
     */
    private static void listDept(String accessToken){
        String url = "https://qyapi.weixin.qq.com/cgi-bin/department/list?access_token=%s";
        com.alibaba.fastjson.JSONObject re = HttpUt.sendGet(String.format(url, accessToken));
        System.out.println(re.toJSONString());
    }


    /**
     * 获取部标签列表
     * @param accessToken
     */
    private static void listTag(String accessToken){
        String url = "https://qyapi.weixin.qq.com/cgi-bin/tag/list?access_token=%s";
        com.alibaba.fastjson.JSONObject re = HttpUt.sendGet(String.format(url, accessToken));
        System.out.println(re.toJSONString());
    }

}
